﻿using System;
using System.Data;

using Wicresoft.Common;

[Table("AttendenceSign", "", "Attendences.ConnectionString")]
public class AttendenceSign : Info
{
    #region SQL column name consts
    public const string SQLCOL_ID = "ID";
    public const string SQLCOL_SIGNUSER = "SignUser";
    public const string SQLCOL_SIGNDISPLAYNAME = "SignDisplayName";
    public const string SQLCOL_SIGNTIME = "SignTime";
    public const string SQLCOL_DEPARTMENTID = "DepartmentID";
    public const string SQLCOL_DEPARTMENTDISPLAYNAME = "DepartmentDisplayName";
    #endregion


    #region Contructors
    /// <summary>
    /// Construct empty entity
    /// </summary>
    public AttendenceSign() { }

    /// <summary>
    /// Construct entity by primary key, other fields will be assigned by 
    /// "Load" method.
    /// </summary>
    public AttendenceSign(int ID)
    {
        this.ID = ID;
    }
    #endregion

    public override void Init(DataRow row)
    {
        ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
        SignUser = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_SIGNUSER]);
        SignDisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_SIGNDISPLAYNAME]);
        SignTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_SIGNTIME]);
        DepartmentID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_DEPARTMENTID]);
        DepartmentDisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DEPARTMENTDISPLAYNAME]);
    }

    #region Properties
    #region Property <int> ID
    [Property("ID", 4, SqlDbType.Int, true, true)]
    public int ID
    {
        get { return _ID; }
        set { _ID = value; }
    }
    private int _ID = int.MinValue;
    #endregion

    #region Property <string> SignUser
    [Property("SignUser", 100, SqlDbType.NVarChar, false, false)]
    public string SignUser
    {
        get { return _SignUser; }
        set { _SignUser = value; }
    }
    private string _SignUser = null;
    #endregion

    #region Property <string> SignDisplayName
    [Property("SignDisplayName", 100, SqlDbType.NVarChar, false, false)]
    public string SignDisplayName
    {
        get { return _SignDisplayName; }
        set { _SignDisplayName = value; }
    }
    private string _SignDisplayName = null;
    #endregion

    #region Property <DateTime> SignTime
    [Property("SignTime", 16, SqlDbType.DateTime, false, false)]
    public DateTime SignTime
    {
        get { return _SignTime; }
        set { _SignTime = value; }
    }
    private DateTime _SignTime = DateTime.MinValue;
    #endregion

    #region Property <Guid> DepartmentID
    [Property("DepartmentID", 16, SqlDbType.UniqueIdentifier, false, false)]
    public Guid DepartmentID
    {
        get { return _DepartmentID; }
        set { _DepartmentID = value; }
    }
    private Guid _DepartmentID = Guid.Empty;
    #endregion

    #region Property <string> DepartmentDisplayName
    [Property("DepartmentDisplayName", 100, SqlDbType.NVarChar, false, false)]
    public string DepartmentDisplayName
    {
        get { return _DepartmentDisplayName; }
        set { _DepartmentDisplayName = value; }
    }
    private string _DepartmentDisplayName = null;
    #endregion
    #endregion


    public bool LoadByIdentity(int ID)
    {
        return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
    }


    public bool DeleteByIdentity()
    {
        return DataAccess.DeleteByIdentity(this);
    }
}
